package com.mk.admin.service.impl;

import com.mk.admin.mapper.RAdminDoctorMapper;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.entity.RAdminDoctorEntity;
import com.mk.admin.model.vo.RAdminDoctorVo;
import com.mk.admin.service.RAdminDoctorService;
import com.mk.admin.util.DateTool;
import com.mk.admin.util.JSONCopy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RAdminDoctorServiceImpl implements RAdminDoctorService {
    @Autowired
    private RAdminDoctorMapper rAdminDoctorMapper;

    @Override
    public ResultDto add(RAdminDoctorVo rAdminDoctorVo) {
        RAdminDoctorEntity entity = JSONCopy.copy(rAdminDoctorVo, RAdminDoctorEntity.class);
        entity.setCreateTime(DateTool.format());
        return ResultDto.data(rAdminDoctorMapper.insert(entity));
    }

    @Override
    public ResultDto update(RAdminDoctorVo rAdminDoctorVo) {
        RAdminDoctorEntity entity = JSONCopy.copy(rAdminDoctorVo, RAdminDoctorEntity.class);
        entity.setUpdateTime(DateTool.format());
        return ResultDto.data(rAdminDoctorMapper.updateById(entity));
    }

    @Override
    public ResultDto delete(int id) {
        return ResultDto.data(rAdminDoctorMapper.deleteById(id));
    }

    @Override
    public ResultDto status(int id) {
        return ResultDto.data(rAdminDoctorMapper.status(id));
    }
}
